#pragma once
#ifndef _GLENV_H
#define _GLENV_H

#include <Windows.h>
#include <gl/glut.h>

#include "Ptr.hpp"

class GlControl
{
private:
  int _timerDuration;
  int _timerInitValue;
public:
  GlControl () : _timerDuration (0), _timerInitValue (0) {}

  // enable opengl feature and set default background color here
  virtual void init_render () = 0;
  virtual void draw () = 0;

  virtual void handle_keypress (unsigned char key, int x, int y) {}
  virtual void handle_special_keypress (int key, int x, int y) {}
  virtual void handle_mouse (int button, int state, int x, int y) {}
  virtual int handle_timer (int val) { return 0; }
  
  virtual int get_timer_duration () const { return _timerDuration; }
  virtual void set_timer_duration (int millisecond) {_timerDuration = millisecond;}
  
  // timer init val is the init value that handle timer receive
  virtual int get_timer_init_val () const { return _timerInitValue; }
  // timer init val is the init value that handle timer receive
  virtual void set_timer_init_val (int val) { _timerInitValue = val; }
};


void glenv_create_window (UINT mode, const char* title, bool isFullScreen,
                          int width = 0, int height = 0,
                          int posX = 0, int posY = 0);

void glenv_run (Ptr< GlControl > control);

#endif